-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(astro): prerendering issue when path contains underscore #11243
fix(astro): prerendering issue when path contains underscore #11243
Conversation
🦋 Changeset detectedLatest commit: 59d11e7 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Quick note: packages/astro/test/fixtures/_underscore in folder name/node_modules/fake-astro-library/ is there on purpose to simulate case when page is exposed by a third-party library. |
4853821
to
cdad175
Compare
// Normalize the file directory path by removing the pagesDir prefix if it exists, | ||
// otherwise remove the rootDir prefix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment should also explain why this is necessary. The code itself isn't too complicated to understand, so a comment that explains it seems superfluous. However, it's worth adding an explanation of the motive because if you left a comment here, it means there's a particular case to handle :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might happen that a page is located in
node_modules
, and the Astro project itself is in a path containing the_
character. In such cases, we should use a relative path to bypass the segment containing_
.
WDYT?
Co-authored-by: Emanuele Stoppa <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great test, thanks!
astro/packages/astro/src/core/util.ts
Lines 122 to 129 in 769f11f
Notice the condition in line 124. It checks for the presence of
_
in any part of the URL. The problem is that file is an absolute path, so_GITHUB
is picked up by this condition, causing the page to be considered 'not public'.Changes
Updated isPublicRoute to use relative paths, ensuring correct handling of underscore folders outside the repository. This change ensures the function correctly returns 'true' when an underscore folder is present outside the repository folder, as intended.
Closes #11232
Testing
Added automated test to cover edge cases involving underscores in paths.
Docs
No update needed